﻿@model zichan.Models.AssetModel
@{
    ViewBag.Title = "添加资产";
}

@section Pagetitle{
    @AdminCommon.PageTitle("资产管理", "添加")
}
@section header{
    <link rel="stylesheet" type="text/css" href="/assets/global/plugins/select2/select2.css" />
    <link href="/assets/global/css/plugins.css" rel="stylesheet" type="text/css" />
}
@using (Html.BeginForm("Create", "Assetes", FormMethod.Post, new { @class = "form-horizontal" }))
{
    <div class="form-body">

        @Html.AntiForgeryToken()

        <div class="form-group ">
            <label class="col-md-3 control-label xh">资产分类:</label>
            <div class="col-md-9">
                @Html.DropDownList("AssetClassId", (SelectList)ViewBag.AssetClassId, "资产分类", new { @class = "form-control input-large" })
                <span class="help-block">
                    @Html.ValidationMessageFor(o => o.AssetClassId)
                </span>
            </div>
        </div>
        <div class="form-group " id="ServerIdentity" style="display:none">
            <label class="col-md-3 control-label xh">资产标识:</label>
            <div class="col-md-9">
                <select name="Identitys" id="Identitys" class="form-control select2 input-large">
                    @*@if (!string.IsNullOrEmpty(@ViewBag.Identitys))
                    {
                    <option value="@ViewBag.Identitys" selected>@ViewBag.Identitys</option>
                    }*@
                    @foreach (var s in ViewBag.Identitys)
                    {
                        <option value="@s" selected>@s</option>
                    }
                </select>
            </div>
        </div>
        <div class="form-group ">
            <label class="col-md-3 control-label xh">所属公司:</label>
            <div class="col-md-9">
                @Html.DropDownList("CompanyId", (SelectList)ViewBag.CompanyId, "请选择", new { @class = "form-control input-large" })
                <span class="help-block">
                    @Html.ValidationMessageFor(o => o.CompanyId)
                </span>
            </div>
        </div>

        <div class="form-group ">
            <label class="col-md-3 control-label xh">资产名称:</label>
            <div class="col-md-9">
                @Html.TextBoxFor(o => o.Name, new { @class = "form-control input-large" })
                <span class="help-block">
                    @Html.ValidationMessageFor(o => o.Name)
                </span>
            </div>
        </div>


        <div class="form-group ">
            <label class="col-md-3 control-label xh">资产数量:</label>
            <div class="col-md-9">
                @Html.TextBoxFor(o => o.Number, new { @class = "form-control input-small" })
                <span class="help-block">
                    @Html.ValidationMessageFor(o => o.Number)
                </span>
            </div>
        </div>

        <div class="form-group ">
            <label class="col-md-3 control-label xh">采购人:</label>
            <div class="col-md-9">
                @Html.DropDownList("BuyerId", (SelectList)ViewBag.BuyerId, "请选择", new { @class = "form-control select2 input-small" })
                <span class="help-block">
                    @Html.ValidationMessageFor(o => o.BuyerId)
                </span>
            </div>
        </div>

        <div class="form-group ">
            <label class="col-md-3 control-label xh">采购时间:</label>
            <div class="col-md-9">
                <div class="input-group">
                    @Html.TextBoxFor(o => o.BuyTime, new { @class = "form-control input-small BuyTime" })
                    <span class="col-md-addtime BuyTime">
                        <i class="fa fa-calendar bigger-110 "></i>
                    </span>
                    <span class="help-block">
                        @Html.ValidationMessageFor(o => o.BuyTime)
                    </span>
                    </div>
                </div>
        </div>

        <div class="form-group">
            <label class="col-md-3 control-label xh">接收人:</label>
            <div class="col-md-9">
                @Html.DropDownList("Recipient", (SelectList)ViewBag.Recipient, "请选择", new { @class = "form-control select2 input-small" })
                <span class="help-block">
                    @Html.ValidationMessageFor(o => o.Recipient)
                </span>
            </div>
        </div>

        <div class="form-group">
            <label class="col-md-3 control-label">接收地:</label>
            <div class="col-md-9">
                @Html.TextBoxFor(o => o.CalculatedGround, new { @class = "form-control input-large" })
            </div>
        </div>

        <div class="form-group">
            <label class="col-md-3 control-label">供应商:</label>
            <div class="col-md-9">
                @Html.TextBoxFor(o => o.Supplier, new { @class = "form-control input-large" })
            </div>
        </div>

        <div class="form-group">
            <label class="col-md-3 control-label">备注:</label>
            <div class="col-md-9">
                @Html.TextAreaFor(o => o.Remark, new { @class = "form-control input-large" })
            </div>
        </div>

        <div class="form-actions">
            <div class="row">
                <div class="col-md-offset-3 col-md-9">
                    <button type="submit" class="btn green">提交</button>
                    <a href="/Assetes/Index" class="btn default">返回</a>
                </div>
            </div>
        </div>
    </div>
}


@section footer{
@Scripts.Render("~/bundles/jqueryval")
    <script src="/assets/global/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
   <script type="text/javascript" src="/assets/global/plugins/select2/select2.min.js"></script>
     <script type="text/javascript">
        var formatDateTime = function (date) {
            var y = date.getFullYear();
            var m = date.getMonth() + 1;
            var d = date.getDate();
            return y+'/'+m+'/'+ d;
        };
        var currDate = 10;
        var currMonth = 10;
        var currYear = 2016;
        var dateStr = new Date(currMonth + "/" + currDate + "/" + currYear);

        $('.BuyTime').datetimepicker({
            //language: 'zh-CN',
            weekStart: 1,
            todayBtn: 0,
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            forceParse: 0,
            endDate: formatDateTime(new Date()),
            minView: 'month',　　　　//日期时间选择器所能够提供的最精确的时间选择视图。
            format: 'yyyy/m/d'
        }).on('changeDate', function (ev) {
            $("#BuyTime").val(formatDateTime(new Date(ev.date.valueOf() - 28800000)));
        });
        $(function () {
            $("#AssetClassId").on("click", function () {
                var s = $("#AssetClassId").val();
                if (s == 1) {
                    $("#ServerIdentity").css({ "display": "block" });
                }
                else {
                    $("#ServerIdentity").css({ "display": "none" });
                }
            });
            $('#BuyerId').select2({
                placeholder: "",
                allowClear: false

            });
            $('#Recipient').select2({
                placeholder: "",
                allowClear: false

            });
        });
    </script>
}